<template>
    <div>
        <input ref="searchVal" type="text"/><button @click="search"> 搜索</button>
        <div @click="$router.push({name:'detail',params:i})" v-for="(i,index) in list" :key="index">{{i.title}}</div>
    </div>
</template>
<script>
import axios from 'axios'
export default {
    data(){
        return {
            list:[]
        }
    },
    mounted(){
        axios.get('/list').then(data=>{
            this.list = data.data
        })
    },
    methods:{
        search(){
             axios.post('/search',{key:this.$refs.searchVal.value}).then(data=>{
                this.list = data.data
                this.$refs.searchVal.value = ''
            })
        }
    }
}
</script>